//
//  Task.h
//  BlockQueue
//
//  Created by 卜绎皓 on 2023/2/11.
//

#ifndef Task_h
#define Task_h


#endif /* Task_h */
#pragma once
#include <iostream>
#include <time.h>

class Task
{
public:
    Task(int x = 0, int y = 0, int op = 0)
        : _x(x), _y(y), _op(op)
    {}
    ~Task()
    {}
    void Run()
    {
        int result = 0;
        switch (_op)
        {
        case '+':
            result = _x + _y;
            break;
        case '-':
            result = _x - _y;
            break;
        case '*':
            result = _x * _y;
            break;
        case '/':
            if (_y == 0){
                std::cout << "Warning: div zero!" << std::endl;
                result = -1;
            }
            else{
                result = _x / _y;
            }
            break;
        case '%':
            if (_y == 0){
                std::cout << "Warning: mod zero!" << std::endl;
                result = -1;
            }
            else{
                result = _x % _y;
            }
            break;
        default:
            std::cout << "error operation!" << std::endl;
            break;
        }
        std::cout << _x << _op << _y << "=" << result << std::endl;
    }
private:
    int _x;
    int _y;
    char _op;
};
